package com.twosnail.frame.model;

import com.jfinal.log.Logger;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;

/**
 * Created by yangcs on 2017/7/24.
 */
public class XdCoupon extends Model<XdCoupon> {
    private Logger logger = Logger.getLogger(XdCoupon.class) ;
    public static final XdCoupon me = new XdCoupon() ;

    public void updateState(long xdCouponId){
        XdCoupon xdCoupon = new XdCoupon();
        xdCoupon.set("xdCouponId",xdCouponId);
        xdCoupon.set("useTime",null);
        xdCoupon.set("state",1);
        xdCoupon.update();
    }

    public void updateState1(long xdCouponId){
        XdCoupon xdCoupon = new XdCoupon();
        xdCoupon.set("xdCouponId",xdCouponId);
        xdCoupon.set("state",3);
        xdCoupon.update();
    }

    /**
     * 过期代金劵无效
     */
    public void refund(){
        Db.update("UPDATE xd_coupon g SET g.state = 4 where expTime < "+System.currentTimeMillis());
    }
}
